package com.sztle.admodule.someutils;

import androidx.annotation.NonNull;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeUtils {

    public static SimpleDateFormat getSafeDateFormat(String pattern) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return simpleDateFormat;
    }

    private static SimpleDateFormat getDefaultFormat() {
        return getSafeDateFormat("  yyyy/MM/dd HH:mm:ss");
    }

    public static String millis2String(final long millis) {
        return millis2String(millis, getDefaultFormat());
    }

    public static String millis2String(final long millis, @NonNull final DateFormat format) {
        return format.format(new Date(millis));
    }

    private static SimpleDateFormat getMSFormat(){
        return getSafeDateFormat("mm:ss");
    }
    public static String millis2StringMs(final long millis){
        return millis2String(millis, getMSFormat());
    }


}
